﻿namespace StockAnalyst2.StockGrid
{
	internal static class ColumnOptionsDataSource
	{
		public static ColumnOptions Load(string columnName)
		{
			ColumnOptions result = new ColumnOptions(columnName);

			result.Visible = (bool)Properties.Settings.Default[columnName + "Visible"];
			result.DisplayIndex = (int)Properties.Settings.Default[columnName + "DisplayIndex"];
			result.NotifyChange = (bool) Properties.Settings.Default[columnName + "NotifyChange"];
			result.DisplayArrow = (bool)Properties.Settings.Default[columnName + "DisplayArrow"];
			result.ColorValue = (bool)Properties.Settings.Default[columnName + "ColorValue"];
			result.Limit = (decimal)Properties.Settings.Default[columnName + "Limit"];

			return result;
		}

		public static void Save(ColumnOptions columnOptions)
		{
			Properties.Settings.Default[columnOptions.ColumnName + "Visible"] = columnOptions.Visible;
			Properties.Settings.Default[columnOptions.ColumnName + "DisplayIndex"] = columnOptions.DisplayIndex;
			Properties.Settings.Default[columnOptions.ColumnName + "NotifyChange"] = columnOptions.NotifyChange;
			Properties.Settings.Default[columnOptions.ColumnName + "DisplayArrow"] = columnOptions.DisplayArrow;
			Properties.Settings.Default[columnOptions.ColumnName + "ColorValue"] = columnOptions.ColorValue;
			Properties.Settings.Default[columnOptions.ColumnName + "Limit"] = columnOptions.Limit;
		}
	}
}
